package com.lily.ssm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lily.ssm.mapper.ProductClassMapper;
import com.lily.ssm.model.ProductClass;


@Service
public class ProductClassService {
	@Autowired
	private ProductClassMapper productClassMapper;
	/*
	 * 查询所有一级分类
	 */
	public List<ProductClass> getList(){
		return productClassMapper.getBigClass();
	}
	
	/*
	 * 根据ID查询
	 */
	public ProductClass getClass(int classId){
		return productClassMapper.selectByPrimaryKey(classId);
	}
	
	/*
	 * 根据一级分类查询相应的二级分类
	 */
	public  List<ProductClass> smaClass(int classId){
		return productClassMapper.getSmallClass(classId);
	}
	
	/*
	 * 修改
	 */
	public int updateProduct(ProductClass record){
		return productClassMapper.updateByPrimaryKeySelective(record);
	}
	
	/*
	 * 删除
	 */
	public int deleteProduct(int classId){
		return productClassMapper.deleteByPrimaryKey(classId);
	}
	
	/*
	 * 新增
	 */
	public int insertProductClass(ProductClass record){
		return productClassMapper.insert(record);
	}
}
